package com.foreveross.vo;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.foreveross.common.Constants;

/**
 * HouseLease entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "house_lease", catalog = "hrtenement")
public class HouseLease implements java.io.Serializable {

	// Fields

	private String id;
	private String title;
	private String image;
	private Double rent;
	private String room;
	private String office;
	private String toilet;
	private String upholstering;
	private String acreage;
	private String aspect;
	private String storey;
	private String roomPlanning;
	private String propertyDescription;
	private String contactPerson;
	private String phone;
	private HrCode housingArea;
	private HrHouses houseId;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date creationTime;
	private Date updateTime;
	private String top;
	private Object other;
	private String absoluteImage;

	// Constructors

	/** default constructor */
	public HouseLease() {
	}

	/** minimal constructor */
	public HouseLease(String id) {
		this.id = id;
	}

	/** full constructor */
	public HouseLease(String id, String title, String image, Double rent,
			String room, String office, String toilet, String upholstering,
			String acreage, String aspect, String storey, String roomPlanning,
			String propertyDescription, String contactPerson, String phone,
			HrCode housingArea, HrHouses houseId, Date creationTime,Date updateTime,String top) {
		this.id = id;
		this.title = title;
		this.image = image;
		this.rent = rent;
		this.room = room;
		this.office = office;
		this.toilet = toilet;
		this.upholstering = upholstering;
		this.acreage = acreage;
		this.aspect = aspect;
		this.storey = storey;
		this.roomPlanning = roomPlanning;
		this.propertyDescription = propertyDescription;
		this.contactPerson = contactPerson;
		this.phone = phone;
		this.housingArea = housingArea;
		this.houseId = houseId;
		this.creationTime = creationTime;
		this.updateTime = updateTime;
		this.top = top;
	}

	// Property accessors
	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "title")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "image")
	public String getImage() {
		return this.image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	@Column(name = "rent", precision = 10)
	public Double getRent() {
		return this.rent;
	}

	public void setRent(Double rent) {
		this.rent = rent;
	}

	@Column(name = "room")
	public String getRoom() {
		return this.room;
	}

	public void setRoom(String room) {
		this.room = room;
	}

	@Column(name = "office")
	public String getOffice() {
		return this.office;
	}

	public void setOffice(String office) {
		this.office = office;
	}

	@Column(name = "toilet")
	public String getToilet() {
		return this.toilet;
	}

	public void setToilet(String toilet) {
		this.toilet = toilet;
	}

	@Column(name = "upholstering")
	public String getUpholstering() {
		return this.upholstering;
	}

	public void setUpholstering(String upholstering) {
		this.upholstering = upholstering;
	}

	@Column(name = "acreage")
	public String getAcreage() {
		return this.acreage;
	}

	public void setAcreage(String acreage) {
		this.acreage = acreage;
	}

	@Column(name = "aspect")
	public String getAspect() {
		return this.aspect;
	}

	public void setAspect(String aspect) {
		this.aspect = aspect;
	}

	@Column(name = "storey")
	public String getStorey() {
		return this.storey;
	}

	public void setStorey(String storey) {
		this.storey = storey;
	}

	@Column(name = "room_planning")
	public String getRoomPlanning() {
		return this.roomPlanning;
	}

	public void setRoomPlanning(String roomPlanning) {
		this.roomPlanning = roomPlanning;
	}

	@Column(name = "property_description")
	public String getPropertyDescription() {
		return this.propertyDescription;
	}

	public void setPropertyDescription(String propertyDescription) {
		this.propertyDescription = propertyDescription;
	}

	@Column(name = "contact_person")
	public String getContactPerson() {
		return this.contactPerson;
	}

	public void setContactPerson(String contactPerson) {
		this.contactPerson = contactPerson;
	}

	@Column(name = "phone")
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "housing_area")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrCode getHousingArea() {
		return this.housingArea;
	}

	public void setHousingArea(HrCode housingArea) {
		this.housingArea = housingArea;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "house_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrHouses getHouseId() {
		return this.houseId;
	}

	public void setHouseId(HrHouses houseId) {
		this.houseId = houseId;
	}

	@Column(name = "creation_time")
	public Date getCreationTime() {
		return this.creationTime;
	}

	public void setCreationTime(Date creationTime) {
		this.creationTime = creationTime;
	}
	
	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "top")
	public String getTop() {
		return top;
	}

	public void setTop(String top) {
		this.top = top;
	}

	
	@Transient
	public String getAbsoluteImage() {
		if(this.getImage()!=null)
			return this.getImage().replace("/fileupload/", Constants.WEBAPP_PATH+"/fileupload/");
		return absoluteImage;
	}

	public void setAbsoluteImage(String absoluteImage) {
		this.absoluteImage = absoluteImage;
	}
	
	@Transient
	public Object getOther() {
		return other;
	}

	public void setOther(Object other) {
		this.other = other;
	}

}